package com.craney.aboutNamesapce
{
	import flash.display.Sprite;
	
	public class XMLNamespace
	{
		public function XMLNamespace(ps:Sprite)
		{
			var catalog:XML = <html xmlns:shop="http://www.example.com/furniture"
				xmlns="http://www.w3.org/1999/xhtml">
					<head>
						<title>Catalog</title>
					</head>
					<body>
						<shop:table shop:id="4875">
							<table border="1">
								<tr align="center">
									<td>Item</td>
									<td>Price</td>
								</tr>
								<tr align="left">
									<td><shop:desc>3-legged Coffee Table</shop:desc></td>
									<td><shop:price>79.99</shop:price></td>
								</tr>
							</table>
						</shop:table>
					</body>
				</html>;
			var defaultNamespace:Namespace = new Namespace("http://www.w3.org/1999/xhtml");
			var shopNamespace:Namespace = new Namespace("http://www.example.com/furniture");
			default xml namespace = defaultNamespace;
			trace(catalog.body.shopNamespace::table.table.tr.td[0]);
//			trace(catalog..shopNamespace::price);
			
			
			
			
			var craney:XML = <guitar name="suffer" xmlns="http://www.guitar.org/" xmlns:halfna="This is a test" >
			
					<first color="blue">
						<price>200</price>
					</first>
					
					<halfna:second halfna:color="woodful">
						<price xmlns="myPrice" xmlns:xx="xx" xx:type="RMB" noNs="right">700</price>
					</halfna:second>
					<a aa="wewe"/>
				</guitar>;
			
			var half:Namespace = craney.namespace("halfna");
			var def:Namespace = craney.namespace();
			var pr:Namespace = new Namespace("myPrice");
			var p:Namespace = craney.half::second.*[0].namespace();
			var x:Namespace = craney.half::second.*[0].namespace("xx");
			
			default xml namespace = def;
			trace(craney.first.price[0]);
			
			
//			for each(var xl:XML in craney..@*)
//			{
//				trace(xl.name() + " = " + xl);
//			}
//			trace(craney.def::first);
//			trace(craney.def::first);
//			trace(def);
//			trace(craney);
//			trace(p);
//			trace(craney.half::second.p::price.@x::type);
//			trace(craney.def::first);

			var third:XML = <a xmlns:def="http://www.guitar.org/">
					<def:b attr="Mary">bbbb</def:b>
					<b>cccc</b>
				</a>;
				
			var t:Namespace = new Namespace("heather", "test");
//			trace(third.b);
//			trace(third.def::b);
//			trace(third);
			default xml namespace = "";
			var forth:XML = <f xmlns:jio="test" jio:s="ssss">fffff<e xmlns:jio="newTest">eeee</e><e>sdfa</e></f>;
			forth.addNamespace(t);
			var tests:Namespace = new Namespace("test");
			trace(forth.e);
//			trace(third.t::b.toXMLString());
//			trace(third..@attr);

		}

	}
}